package com.example.asset.controller;

import cn.hutool.core.collection.CollUtil;
import com.example.asset.common.Result;
import com.example.asset.entity.SysUser;
import com.example.asset.entity.vo.KeyVal;
import com.example.asset.service.AssetInformationService;
import com.example.asset.service.AssetLendService;
import com.example.asset.service.AssetMaintainService;
import com.example.asset.service.SysUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 首页看板echarts
 */
@Tag(name = "首页看板echarts")
@RestController
@RequestMapping("/echarts")
public class EchartsController{

    @Autowired
    private AssetInformationService assetInformationService;

    @Autowired
    private SysUserService sysUserService;

    @Autowired
    private AssetLendService assetLendService;

    @Autowired
    private AssetMaintainService assetMaintainService;

    /**
     * 资产状态
     *
     * @return
     */
    @Operation(summary = "资产状态")
    @GetMapping("/states")
    private Result AssetState(){
        List<KeyVal> informations = assetInformationService.listState();
        return Result.success(informations);
    }

    /**
     * 用户性别比例
     *
     * @return
     */
    @Operation(summary = "用户部门比例")
    @GetMapping("/userDepart")
    private Result userDepart(){
        List<KeyVal> informations = sysUserService.userDepart();
        return Result.success(informations);
    }

    /**
     * 借出计数
     *
     * @return
     */
    @Operation(summary = "借出计数")
    @GetMapping("/lendcount")
    private Result LendCount(){
        return Result.success(assetLendService.CountLend());
    }

    /**
     * 资产总价
     *
     * @return
     */
    @Operation(summary = "资产总价")
    @GetMapping("/assetmoney")
    public Result AssetMoney(){
        return Result.success(assetInformationService.AssetMoney());
    }

    /**
     * 资产总数
     *
     * @return
     */
    @Operation(summary = "资产总数")
    @GetMapping("/assetcount")
    public Result AssetCount(){
        return Result.success(assetInformationService.AssetCount());
    }

    /**
     * 维修总数
     *
     * @return
     */
    @Operation(summary = "维修总数")
    @GetMapping("/maintaincount")
    public Result MaintainCount(){
        return Result.success(assetMaintainService.maintainCount());
    }


}